﻿<%@ 
page language="java" 
import="java.util.*" 
import="com.csd.helper.IConstant"
import="com.csd.helper.Tool"
import="com.csd.helper.ProjectState"
import="com.csd.vo.UserVO"
import="com.csd.pojo.CostRecord"
pageEncoding="UTF-8"
%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ page isELIgnored="false" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
HttpSession s = request.getSession();
UserVO uvo =  (UserVO)s.getAttribute(IConstant.userVO);
if(uvo==null || !uvo.getType().equals(IConstant.teamRole))
{
	response.sendRedirect(path);
}
String user_name = uvo.getName();

List<CostRecord> costList = (List<CostRecord>) request.getAttribute("list");

if(costList==null)
{
	costList = new ArrayList<CostRecord>();
}

String projstat = (String)request.getAttribute("projectState");

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>变更</title>
<link href="<%=path %>/student/css/student_right.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=path %>/student/js/check.js"></script>

<script type="text/javascript" src="<%=path %>/student/js/PopupCalendar.js" ></script>
<script type="text/javascript">
	var oCalendarEn=new PopupCalendar("oCalendarEn");
	oCalendarEn.Init();
</script>

<script type="text/javascript">
function cls(){
var area=document.getElementsByName('record.detail')
if( area[0].value== '经费支出理由...'){area[0].value =""; area[0].style.color = '#000000'; }
}

function hint(){
var area=document.getElementsByName('record.detail')
if(area[0].value == ""){area[0].style.color = '#ACA899'; area[0].value = '经费支出理由...'; }
}

function hintForLength(){
var detail = document.getElementsByName('record.detail');
if(detail[0].value.length >= 200){
document.getElementById('error1').innerHTML = "最多输入200字理由";
}else{
document.getElementById('error1').innerHTML = "";
}
}

function checkCost(form){
var flag=true;
var detail = document.getElementsByName('record.detail');
var time = document.getElementsByName('record.time');
var money = document.getElementsByName('record.money');
flag = checkForm(form);
if(time[0].value.length == 0 || money[0].value.length == 0){
flag = false;
}
if(detail[0].value.length == 0 || detail[0].value == "经费支出理由..."){
flag = false;
detail[0].focus();
}
return flag;
}
</script>

</head>


<body onload="hint()">
    <div class="main">
        <h1>我的经费记录</h1>
        <hr />

        <h3>&nbsp;</h3>
        <table width="100%" style="table-layout:fixed;word-wrap:break-word;">          
            <tr>
            	<td class="table_head" width="150px">开支日期</td> 
              	<td class="table_head" width="100px">开支金额(元)</td> 
              	<td class="table_head">开支描述</td> 
            </tr> 
            
          <%if(costList.size()>0) {
          		for(CostRecord i : costList)
          		{
          %>    
             
            <tr>
            	<td><%=Tool.dateToString( i.getTime() ) %></td> 
              	<td><%=i.getMoney() %></td> 
              	<td><%=i.getDetail() %></td> 
            </tr> 
           <%} %>
          <%}else{ %>
           <tr> 
            <td colspan="3" align="center">暂无记录</td>  
          </tr>           
          <%} %>

        </table> 
        
        <% if(projstat == null || 
			  projstat.equals(ProjectState.apply) ||
			  projstat.equals(ProjectState.prophase) ||
			  projstat.equals(ProjectState.proHaveScore) ||
			  projstat.equals(ProjectState.prophaseReject) ||
			  projstat.equals(ProjectState.projectEnd) ||
			  projstat.equals(ProjectState.finishApply)||
			  projstat.equals(ProjectState.telophasePass) ||
			  projstat.equals(ProjectState.waitReview)
			  )
		{
		%>
			<h3>开支记录不可更新，你可能暂未申请项目，或者项目已被冻结</h3>
		<%}else{ %>
        
        <h3>加入新的开支记录</h3>
        <form action="costRecord.action" method="post" onsubmit="return checkCost(this);" >
	        <table width="100%" align="center"> 
	          <tr> 
	            <td class="form_strong" width="150px">使用时间：</td> 
	            <td>
	                <input readonly="readonly" type="text" name="record.time" onclick="getDateString(this,oCalendarEn);" onchange="checkDate(this);" />               
	            </td> 
	          </tr> 
	          <tr> 
	            <td class="form_strong">金额（单位￥）：</td> 
	            <td> 
	            	<input type="text" maxLength="10" name="record.money" onblur="checkMoney(this);" />	              
	            </td> 
	          </tr> 
	          <tr> 
	            <td class="form_strong">开支描述：</td> 
	            <td>
	                <textarea name="record.detail" id="textarea" cols="45" rows="5" 
	                onblur="checkNotNull(this);hint();" onfocus="cls();checkNotNull(this);" 
	                style="color:#ACA899;" 
	                onkeyup="checkNotNull(this);hintForLength();checkTextAreaLength(this,0,200);"
	                onkeydown="checkTextAreaLength(this,0,200);"></textarea> 
	            </td> 
	          </tr> 
	          <tr><td colspan="2" align="center">
	          <span id="error1" style="text-align:center; color:#FF0000;"></span>
	          </td></tr>
	          <tr> 
	            <td colspan="2" align="center">
	            	<input type="submit" value=" 提交 " /> 
	            </td> 
	          </tr> 
	        </table> 
        </form>
        <%}%>
    </div>
</body>


</html>

